/**
 * 
 */
package com.globallogic.training.university.people;

import java.util.Arrays;
import java.util.Date;

import com.globallogic.training.university.study.Course;

/**
 * Class <code>Teacher</code> represents a teacher of University
 * 
 * @author vasiliy.kulgaviy
 */
public class Teacher extends Person {
	private Course[] courses = new Course[0];

	/**
	 * Constructs a teacher with defined First Name, Last Name and Birth Date
	 * 
	 * @param firstName
	 *            the first name of the new teacher
	 * @param lastName
	 *            the last name of the new teacher
	 * @param birthDate
	 *            the birth date of the new teacher
	 */
	public Teacher(String firstName, String lastName, Date birthDate) {
		super(firstName, lastName, birthDate);
	}

	/**
	 * Returns the courses assigned to the teacher
	 * 
	 * @return the courses of the teacher
	 */
	public Course[] getCourses() {
		return courses;
	}

	/**
	 * Assigns the course to the teacher
	 * 
	 * @param course
	 *            the course to assign to the teacher
	 */
	public void assignCourse(Course course) {
		courses = Arrays.copyOf(courses, courses.length + 1);
		courses[courses.length - 1] = course;
	}

	/**
	 * Determines if the course is assigned to the teacher
	 * 
	 * @param course
	 *            the course to verify its assignment to the teacher
	 * @return true - if the course is assigned to the teacher, otherwise -
	 *         false
	 */
	public boolean hasCourse(Course course) {
		for (Course assignedCourse : courses) {
			if (course.equals(assignedCourse)) {
				return true;
			}
		}

		return false;
	}
}
